<?php if ($section == "proposal_titles") echo "<h3>Associated Course Learning Outcomes</h3>"; elseif ($section != "comments") echo "<a name='lo'></a><h2>Course Learning Outcomes</h2>"; ?>
<?php if ($modal_window != "true") { ?><p><span class="icon"><img src="images/page_add.png" border="0" align="absmiddle" /></span><a id="modal_window_link" href="index.php?section=clo&amp;action=view&amp;go=<?php if (strstr($section, "step")) echo "confirm"; else echo "default"; ?>&amp;view=proposal_detail&amp;cid=<?php echo $cid; ?>&amp;modal_window=true">Add Learning Outcomes</a> (all learning outcomes must be associated with an existing <a id="modal_window_link" href="index.php?section=proj_deliv&amp;action=add&amp;go=<?php if (strstr($section, "step")) echo "confirm"; else echo "default"; ?>&amp;view=proposal_detail&amp;cid=<?php echo $cid; ?>&amp;modal_window=true">project deliverable</a>)<?php } ?>
<?php 
if ($id == "default") { 
	$query_lo = "SELECT * FROM learning_outcomes WHERE cid='$cid'";
	if ($section == "proposal_titles") $query_lo .= " AND mid='$mid' ORDER BY del_num";
	$lo = mysql_query($query_lo, $connection) or die(mysql_error());
	$row_lo = mysql_fetch_assoc($lo);
	$totalRows_lo = mysql_num_rows($lo);
	if ($totalRows_lo > 0) {
		if ($section != "proposal_titles") {
?>
<table class="dataTable">
<tr>
	<th>Upon successful completion of this course, each student will be able to...</th>
	<th width="13%" nowrap="nowrap">&nbsp;</th>
    <?php if ((!strstr($section, "step")) && ($modal_window != "true")) { ?>
    <th width="13%" nowrap="nowrap">ID / Reviewer<br>Comments?</th>
    <th width="13%" nowrap="nowrap">Changes Needed?</th>
    <?php } ?>
    <th width="13%">Associated With</th>
    <?php if ($section == "proposal_reveiw") { ?>
    <th width="13%" nowrap="nowrap">Make Changes?</th>
    <?php } ?>
</tr>
<?php 
do { $c[] = $row_lo['mid']; } while($row_lo = mysql_fetch_assoc($lo));
//print_r($c);
		foreach (array_unique($c) as $value) {
				// Was NOT returning the first row for some reason - found out that you MUST use the do...while loop to build the arrays.
				$query_pd_num = sprintf("SELECT * FROM learning_outcomes WHERE cid='%s' AND mid='%s' ORDER BY mid,del_num", $cid, $value);
				$pd_num = mysql_query($query_pd_num, $connection) or die(mysql_error());
				$row_pd_num = mysql_fetch_assoc($pd_num);
				$totalRows_pd_num = mysql_num_rows($pd_num);
				do { $d[] = $row_pd_num['del_num']; } while ($row_pd_num = mysql_fetch_assoc($pd_num));
				sort($d);
				foreach (array_unique($d) as $value1) {
						$query_lo_loop = sprintf("SELECT * FROM learning_outcomes WHERE cid='%s' AND mid='%s' AND del_num='%s'", $cid, $value, $value1);
						$lo_loop = mysql_query($query_lo_loop, $connection) or die(mysql_error());
						$row_lo_loop = mysql_fetch_assoc($lo_loop);
						$totalRows_lo_loop = mysql_num_rows($lo_loop);
						
						if ($totalRows_lo_loop > 0) { 
							do {
							$query_lo_comments = sprintf("SELECT * FROM comments WHERE (cid='%s' AND tableName='learning_outcomes' AND rid='%s')", $cid, $row_lo_loop['id']);
							$lo_comments = mysql_query($query_lo_comments, $connection) or die(mysql_error());
							$row_lo_comments = mysql_fetch_assoc($lo_comments);
							$totalRows_lo_comments = mysql_num_rows($lo_comments);
							echo "<tr style='background-color: ".$color."'>";
							echo "<td>";
							echo "<div class='stacked'><span class='icon'><img src='images/page_edit.png' align='absmiddle' border='0'></span><a id='modal_window_link'  href='index.php?section=clo&action=edit&go=".$go."&amp;view=proposal_detail&cid=".$cid."&id=".$row_lo_loop['id']."&amp;modal_window=true'>Edit</a></div>";
							echo "<div class='stacked'>".$row_lo_loop['lo_text']."</div>";
							echo "</td>";
							echo "<td class='data'>";
							echo "<div class='stacked'><span class='icon'><img src='images/bin_closed.png' border='0' align='absmiddle' /></span><a href='javascript:confirmation(\"includes/process.inc.php?action=delete&dbTable=learning_outcomes\",\"id\",\"".$row_lo_loop['id']."\",\"Are you sure want to delete this learning outcome?\")'>Delete?</a></div>";
							echo "</td>";
							if (($section != "proposal_reveiw") && ($modal_window != "true")) { 
							echo "<td class='data'>";
							if ($totalRows_lo_comments > 0) echo "<div class='stacked'><span class='icon'><img src='images/comment.png' align='absmiddle' border='0'></span><a class='modal_window_link' href='index.php?section=view_proposal&dbTable=learning_outcomes&cid=".$cid."&id=".$row_lo_loop['id']."#comments' title='View ID Comments'>Yes</a></div>"; else echo "<div class='stacked'><span class='icon'><img src='images/comment_fade.png' align='absmiddle' border='0'></span>No</div>";  if ($row_user['userLevel'] <= "2") echo "<div class='stacked'><span class='icon'><img src='images/comment_add.png' align='absmiddle' border='0'></span><a id='modal_window_link' href='index.php?section=comments&action=add&cid=".$cid."&dbTable=learning_outcomes&id=".$row_lo_loop['id']."&amp;modal_window=true'>Add Comment</a></div>";
							echo "</td>";
							echo "<td class='data'>";
							if ($row_lo_comments['changes'] == "Y") echo "<div class='stacked'><span class='icon'><img src='images/error.png' align='absmiddle' border='0'></span><a id='modal_window_link' href='index.php?section=view_proposal&dbTable=learning_outcomes&cid=".$cid."&id=".$row_lo_loop['id']."&amp;modal_window=true' title='View ID Comments About Changes'>Yes</a>"; else echo "<div class='stacked'><span class='icon'><img src='images/tick.png' align='absmiddle' border='0'></span>No</div>";
							echo "</td>";
							}
							echo "<td class='data'>Course Project Deliverable ".$row_lo_loop['del_num']."</td>";
							if ($section == "proposal_reveiw") { 
							echo "<td class='data'><a href='index.php?section=clo&action=edit&go=review&cid=".$cid."&del_num=".$row_lo_loop['del_num']."&id=".$row_lo_loop['id']."'>Yes</a></td>";
							}
							echo "</tr>";
							if ($color == $color1) { $color = $color2; } else { $color = $color1; }
							} while ($row_lo_loop = mysql_fetch_assoc($lo_loop));
							
						} 
				   }

			}
?>
</table>
<?php 		} // end if ($section != "proposal_titles") ?>
<?php 	} else echo "<div class='error_msg'>There are no learning outcomes associated with this module or project deliverables.</div>"; // end if ($totalRows_lo > "0") ?>
<?php } // end if ($id == "default") ?>
<?php 
if ($id != "default") {
	if ($totalRows_comments > 0) { 
 	if ($row_comments['changes'] == "Y") echo "<div class='error_msg'>Changes are needed to this learning outcome.</div>";
 	} 
?>
<table class="dataTable">
<tr>
	<th>Upon successful completion of this course, each student will be able to...</th>
</tr>
<tr>
	<td><?php echo $row_view_specific['lo_text']; ?></td>
</tr>
</table>
<?php if (($totalRows_comments > 0) && ($section != "comments") && ($section != "view_comments")) { ?>
<a name="comments"></a><h2>ID Comments</h2>
<table class="dataTable">
<tr>
	<th width="10%" nowrap="nowrap">Instructional Designer</th>
    <th>Comments</th>
    <th width="13%">Changes Needed?</th>
    <th width="13%"></th>
</tr>
<?php do { ?>
<tr style="background-color: <?php echo $color; ?>">
	<td width="5%" nowrap="nowrap"><p><?php echo $row_id['firstName']." ".$row_id['lastName']; ?><p></td>
    <td class="data"><?php echo $row_comments['comment']; ?></td>
    <td class="data"><?php  if ($row_comments['changes'] == "Y") echo "<span class='icon'><img src='images/error.png' align='absmiddle' border='0'></span>Yes"; else echo "<span class='icon'><img src='images/tick.png' align='absmiddle' border='0'></span>No";  ?>
    <td class="data">
	<?php if ($row_comments['changes'] == "Y") echo "<a href='index.php?section=clo&action=edit&go=detail&cid=".$cid."&id=".$row_comments['rid']."&amp;modal_window=".$modal_window."'>Make Changes</a>"; else echo ""; ?>
    </td>
</tr>
<?php if ($color == $color1) { $color = $color2; } else { $color = $color1; } ?>
<?php } while ($row_comments = mysql_fetch_assoc($comments)); ?>
</table>
<?php } 
} // end if ($id != "default")
if ($section == "proposal_titles") { 
if ($totalRows_lo > 0) { ?>
<table class="dataTable">
	<tr>
    	<th>Upon successful completion of this course, each student will be able to...</th>
        <th width="13%">Associated With</th>
    </tr>
<?php do { ?>
	<tr style="background-color: <?php echo $color; ?>">
	<td><?php echo $row_lo['lo_text']; ?></td>
	<td class="data">Deliverable <?php echo $row_lo['del_num']; ?></td>
	</tr>
	<?php 
		if ($color == $color1) { $color = $color2; } else { $color = $color1; }
		} while ($row_lo = mysql_fetch_assoc($lo));
	  } else echo "<div class='error_msg'>There are no learning outcomes associated with this module or project deliverables.</div>";
 ?>
</table>
<?php } ?>